package come.bjpowernode.javase.thread;
/*
让位：
    当前线程暂停回到就绪状态。
静态方法：
    Thread.yield();
 */
public class ThreadTest12 {
    public static void main(String[] args) {
        Thread t = new Thread(new MyRunnable6());
        t.setName("t");
        t.start();
        for(int i = 1; i <= 10000; i++){
            System.out.println(Thread.currentThread().getName()+
                    "-->" + i);
        }
    }
}
class MyRunnable6 implements Runnable{
    public void run(){
        for(int i = 1; i <= 10000; i++){
            //每100个让位一次
            if(i%100 == 0){
                Thread.yield();
            }
            System.out.println(Thread.currentThread().getName()+
                    "-->" + i);
        }
    }
}
